//
//  SDTabbarViewManager.m
//  sigleApp
//
//  Created by 徐文强 on 2017/11/20.
//  Copyright © 2017年 coderxu.com. All rights reserved.
//

#import "SDTabbarViewManager.h"
#import "SDHomeViewController.h"
#import "SDForYouViewController.h"
@implementation SDTabbarViewManager
/** 配置viewControllers */
+ (void)configChildViewControllers:(UITabBarController *)tabbarController {
    // Home
    UIViewController *homeViewController = [[UIViewController alloc]init];
    //    homeViewController.view.backgroundColor = [UIColor whiteColor];
    homeViewController.tabBarItem = [self tabBarItemWithTitle:@"Home" imageName:@"xhs_tab_home_normal" selectImageName:@"xhs_tab_Home_selected"];
    UINavigationController *homeViewControllerNav = [[UINavigationController alloc]initWithRootViewController:homeViewController];
    // For you
    UIViewController *forYouController = [[UIViewController alloc]init];
    forYouController.view.backgroundColor = [UIColor whiteColor];
    forYouController.tabBarItem = [self tabBarItemWithTitle:@"For you" imageName:@"xhs_tab_Foryou_normal" selectImageName:@"xhs_tab_Foryou_selected"];
    UINavigationController *forYouControllerNav = [[UINavigationController alloc]initWithRootViewController:forYouController];
    // Live
    UIViewController *liveViewController = [[UIViewController alloc]init];
    liveViewController.view.backgroundColor = [UIColor whiteColor];
    liveViewController.tabBarItem = [self tabBarItemWithTitle:@"Live" imageName:@"xhs_tab_Live_normal" selectImageName:@"xhs_tab_Live_selected"];
    UINavigationController *liveViewControllerNav = [[UINavigationController alloc]initWithRootViewController:liveViewController];
    // Video
    UIViewController *videoViewController = [[UIViewController alloc]init];
    videoViewController.view.backgroundColor = [UIColor whiteColor];
    videoViewController.tabBarItem = [self tabBarItemWithTitle:@"Video" imageName:@"xhs_tab_Video_normal" selectImageName:@"xhs_tab_Video_selected"];
    
    UINavigationController *videoViewControllerNav = [[UINavigationController alloc]initWithRootViewController:videoViewController];
    tabbarController.viewControllers = @[homeViewControllerNav,
                                         forYouControllerNav,
                                         liveViewControllerNav,
                                         videoViewControllerNav];
}

/** 构建TabbarItem */
+ (UITabBarItem *)tabBarItemWithTitle:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName {
    UIImage *userCenterImage = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *userCenterSelectImage = [[UIImage imageNamed:selectImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:userCenterImage selectedImage:userCenterSelectImage];
    tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
    return tabBarItem;
}
@end
